package com.dondedesigns.eh.controller.management;

import com.dondedesigns.eh.persistence.ApprovedStatus;
import com.dondedesigns.eh.persistence.User;
import com.dondedesigns.eh.persistence.dao.UserDAO;
import com.opensymphony.xwork2.ActionSupport;

public class ChangeUserStatus extends ActionSupport{
	
	private String userId;
	private UserDAO userDAO;
	
	@Override
	public String execute() throws Exception {
		User user = userDAO.find(Long.valueOf(userId));
		if (user.getApprovedStatus() == ApprovedStatus.APPROVED) {
			user.setApprovedStatus(ApprovedStatus.DENIED);
		} else {
			user.setApprovedStatus(ApprovedStatus.APPROVED);
		}
		userDAO.update(user);
		return SUCCESS;
	}
	
	public void setUserId(String userId) {
		this.userId = userId;
	}
	
	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}
}
